#include <stdio.h>
#include <stdlib.h>

// 定义顾客结构体
typedef struct {
    int number; // 顾客编号
    int isOdd; // 是否为奇数编号的顾客（A窗口）
} Customer;

// 定义队列结构体
typedef struct {
    Customer* data; // 存储数据的数组
    int front; // 队头指针
    int rear; // 队尾指针
    int capacity; // 队列容量
} Queue;

// 创建队列
Queue* createQueue(int capacity) {
    Queue* queue = (Queue*)malloc(sizeof(Queue));
    queue->data = (Customer*)malloc(capacity * sizeof(Customer));
    queue->front = -1;
    queue->rear = -1;
    queue->capacity = capacity;
    return queue;
}

// 销毁队列
void destroyQueue(Queue* queue) {
    free(queue->data);
    free(queue);
}

// 判断队列是否为空
int isEmpty(Queue* queue) {
    return queue->front == -1;
}

// 入队操作
void enqueue(Queue* queue, Customer customer) {
    if (queue->rear == queue->capacity - 1) {
        // 队列已满，需要扩容
        int size = queue->capacity * sizeof(Customer);
        queue->capacity *= 2;
        queue->data = (Customer*)realloc(queue->data, queue->capacity * sizeof(Customer));
    }
    queue->rear++;
    queue->data[queue->rear] = customer;
    if (queue->front == -1) {
        queue->front = 0;
    }
}

// 出队操作
Customer dequeue(Queue* queue) {
    Customer customer = queue->data[queue->front];
    if (queue->front == queue->rear) {
        // 队列中只有一个元素，出队后队列为空
        queue->front = -1;
        queue->rear = -1;
    } else {
        queue->front++;
    }
    return customer;
}

// 按业务处理顾客序列函数
void processCustomers(Customer* customers, int n) {
    Queue* aQueue = createQueue(n); // A窗口队列
    Queue* bQueue = createQueue(n); // B窗口队列

    for (int i = 0; i < n; i++) {
        if (customers[i].isOdd) {
            enqueue(aQueue, customers[i]);
        } else {
            enqueue(bQueue, customers[i]);
        }
    }

    while (!isEmpty(aQueue) || !isEmpty(bQueue)) {
        if (!isEmpty(aQueue)) {
            Customer customer1 = dequeue(aQueue);
            printf("%d ", customer1.number);
            if (!isEmpty(aQueue)) {
                Customer customer2 = dequeue(aQueue);
                printf("%d ", customer2.number);
            }
        }
        if (!isEmpty(bQueue)) {
            Customer customer = dequeue(bQueue);
            printf("%d ", customer.number);
        }
    }
    printf("\n");

    destroyQueue(aQueue);
    destroyQueue(bQueue);
}

int main() {
    int n; // 顾客总数
    scanf("%d", &n);

    Customer* customers = (Customer*)malloc(n * sizeof(Customer));
    for (int i = 0; i < n; i++) {
        scanf("%d", &customers[i].number);
        customers[i].isOdd = customers[i].number % 2 != 0;
    }

    processCustomers(customers, n);

    free(customers);

    return 0;
}
